<%!
public class XML
{
	org.jdom.Document doc;
	org.jdom.Element cfx;
	XML(String root)
	{
		try{
		cfx = new org.jdom.Element(root);
		doc = new org.jdom.Document(cfx);
		}catch(Exception e)
		{
			System.out.println(e.toString());
			}
		}
	XML()
	{}
	public boolean add(String parent,String node)
	{
		try{
		//org.jdom.Element tmp0=(org.jdom.Element)org.jdom.xpath.XPath.selectNodes(cfx, parent).get(0);
		java.util.List allChildren = ((org.jdom.Element)org.jdom.xpath.XPath.selectNodes(cfx, parent).get(0)).getChildren();//
		org.jdom.Element tmp=new org.jdom.Element(node);
		//tmp0.addContent(tmp);
		allChildren.add(tmp);//
		 return true;
		 }catch(Exception e)
		{
			System.out.println(e.toString());
			return false;
			}
		}
	public boolean set(String nodename,String value)
	{
		try{
		org.jdom.Element tmp=(org.jdom.Element)org.jdom.xpath.XPath.selectNodes(cfx, nodename).get(0);
		tmp.setText(value);
		return true;
		}catch(Exception e)
		{
			System.out.println(e.toString());
			return false;
			}
		}
	public String get(String nodename)
	{
		try{
		org.jdom.Element tmp=(org.jdom.Element)org.jdom.xpath.XPath.selectNodes(cfx, nodename).get(0);
		return tmp.getText();
		}catch(Exception e)
		{
			System.out.println(e.toString());
			return "";
			}
		}
	public String toString()
	{
		try{
    		org.jdom.output.XMLOutputter docOutput = new org.jdom.output.XMLOutputter();
    		java.io.ByteArrayOutputStream byteOut = new java.io.ByteArrayOutputStream();
    		docOutput.output(doc, byteOut);
    		String xml = byteOut.toString();
    		return xml;
    		//return "abc";
    		}catch(Exception e)
		{
			System.out.println(e.toString());
			return "";
			}
    		//return xml;
		}
	public void parse(String xmlstr)
	{
		try{
		java.io.Reader   rd   =   new   java.io.StringReader(   xmlstr   );
			    org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
    			doc = builder.build(rd);
     			cfx = doc.getRootElement();
     			}catch(Exception e)
		{
			System.out.println(e.toString());
			}
		}
	public void load(java.io.File file1)
	{
		try{
    org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder();
     doc = builder.build(file1);
     cfx = doc.getRootElement();
    }catch(Exception e)
	{
	}
}
}

%>
